/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2023-09-21
 * Time: 16:02
 */

//前台线程和后台线程
public class Demo6 {
    public static void main(String[] args) throws InterruptedException {
        Thread t=new Thread(() ->{
            while(true){
                System.out.println("hello world");
            }
        });
        //设置为后台线程
        t.setDaemon(true);
        t.start();
        Thread.sleep(3000);
        System.out.println("主线程结束");
    }
}
